package com.zhongyu.consumer.config;

import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

@Configuration
public class RestConfig {


    @Resource
    private RestTemplateBuilder restTemplateBuilder;

    @Bean
    @LoadBalanced    //负载均衡
    public RestTemplate restTemplate(){
        return restTemplateBuilder.build();
    }

}
